<?php


namespace app\home\controller;


use app\BaseController;
use think\facade\Db;
use think\facade\Session;
use think\facade\View;

class Login extends BaseController
{
    public function index(){
        return View::fetch('login');
    }
    public function login(){
        $account=input('account');
        $password=input('password');
        $vac=Db::name('archives')->where('u_account',$account)->find();
        if(!empty($vac)){
            if($password==$vac['u_password']){
                Session::set('archives',$vac['u_account']);
                Session::set('archid',$vac['u_id']);
                Session::set('archname',$vac['u_name']);
                Session::set('archimg',$vac['u_portrait']);
                Session::set('arcbrief',$vac['u_brief']);
                return json(['status'=>1000,'tips'=>'登陆成功！']);
            }else{
                return json(['status'=>1001,'tips'=>'登陆失败！']);
            }
        }else{
            return json(['status'=>1001,'tips'=>'登陆失败！']);
        }
    }
}